<?php
namespace Home\Controller;

class SmtpController extends CommonController {

	public function _sendmail($uemail,$subject,$body)
	{
		
		$msetting=M('smtp');
		$config_mail = $msetting->find(1);
		$mailend = explode('.',$config_mail['smtp_host']);
        $fromemail = $config_mail['smtp_user'].'@'.$mailend[1].'.'.$mailend[2];//构建邮箱

        $smtpserver     =     $config_mail['smtp_host'];//SMTP服务器
        $smtpserverport =    $config_mail['smtp_port'];//SMTP服务器端口
        $smtpusermail     =     $fromemail;//SMTP服务器的用户邮箱
        $smtpuser         =     $config_mail['smtp_user'];//SMTP服务器的用户帐号
        $smtppass         =     $config_mail['smtp_pass'];//SMTP服务器的用户密码
        $smtpemailto     =     $uemail;//发送给谁
        $mailsubject     =     $subject;//邮件主题
        $mailtime        =    date("Y-m-d H:i:s");
        $mailbody         =     $body;//邮件内容
                 
        $utfmailbody    =    iconv("UTF-8","GB2312",$mailbody);//转换邮件编码 
        $mailtype         =     "HTML";//邮件格式（HTML/TXT）,TXT为文本邮件       
        import ("Org.Util.Smtp");

        $newsmtp = new \Smtp();
        $smtp = $newsmtp->smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
        $newsmtp->debug = FALSE;//是否显示发送的调试信息 FALSE or TRUE
        $ret = $newsmtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $utfmailbody, $mailtype);
	}

	public function index(){
	       $sendmail = "kitwujiajian@sina.com";
           $zhuti = "test smtp";
           $body = "hello world";
           // $this->_sendmail($sendmail,$zhuti,$body);
	}


    public function testajax(){
        $this->ajaxReturn("adsad");
    }









}

?>